function isPhone(rule, val) {
  const reg = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
  return reg.test(val);
}
function isMail(val) {
  /*
    域名后缀最少2位，最多6位，只能是字母，如：cn, top
    域名字符可以为字母(a-z)、数字(0-9)、下划线(_)、连字符(-)四种
    域名可由多级名称构成，但每级开头和结尾只能是字母和数字，如：test_server1.kano-act.org
    用户名可以为字母(a-z)、数字(0-9)、下划线(_)、连字符(-)四种
    用户名可由多级名称构成，但每级开头和结尾只能是字母和数字，如：demo.worker (不太正式，国外有此情况)
    */
  const reg =
    /^((?!-)[\w-]+\.)*(?!-)[\w-]+(?<!-)@((?!-)[\w-]+\.)+[A-Za-z]{2,6}$/;
  return reg.test(val);
}
const verifyRules = {
  user: {
    userName: [
      { required: true, message: '用户名称不能为空', trigger: 'blur' },
      { min: 1, max: 20, message: '用户名称不能超过20个字符', trigger: 'blur' },
    ],
    mobile: [
      { required: true, message: '手机号不能为空', trigger: ['blur'] },
      { validator: isPhone, message: '请输入正确的手机号', trigger: ['blur'] },
    ],
    email: [
      {
        required: true,
        type: 'email',
        message: '请输入正确的邮箱地址',
        trigger: ['blur'],
      },
    ],
    title: [{ required: true, message: '职位不能为空', trigger: ['blur'] }],
  },
  tenant: {
    name: [
      { required: true, message: '租户名称不能为空', trigger: 'blur' },
      { min: 1, max: 30, message: '用户名称不能超过30个字符', trigger: 'blur' },
    ],
    tenantCode: [
      { required: true, message: '租户代码不能为空', trigger: 'blur' },
    ],
    contactsName: [
      { required: true, message: '联系人不能为空', trigger: 'blur' },
    ],
    companyId: [{ required: true, message: '请选择所属公司', trigger: 'blur' }],
    contactsMobile: [
      { required: true, message: '手机号不能为空', trigger: ['blur'] },
      { validator: isPhone, message: '请输入正确的手机号', trigger: ['blur'] },
    ],
    contactsEmail: [
      { required: true, message: '邮箱地址不能为空', trigger: 'blur' },
      { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur'] },
    ],
  },
  company: {
    name: [
      { required: true, message: '公司名称不能为空', trigger: 'blur' },
      { min: 1, max: 30, message: '公司名称不能超过30个字符', trigger: 'blur' },
    ],
    // contactsName: [
    //   { required: true, message: '联系人不能为空', trigger: 'blur' },
    //   { min: 1, max: 20, message: '联系人名称不能超过20个字符', trigger: 'blur' }
    // ],
    // contactsMobile: [
    //   { required: true, message: '手机号不能为空', trigger: ['blur'] },
    //   { validator: isPhone, message: '请输入正确的手机号', trigger: ['blur'] }
    // ],
    // contactsEmail: [
    //   { required: true, message: '邮箱地址不能为空', trigger: 'blur' },
    //   { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur'] }
    // ],
    // contactsAddress: [
    //   { required: true, message: '公司地址不能为空', trigger: 'blur' }
    // ],
    type: [{ required: true, message: '请选择一个公司类型', trigger: 'blur' }],
  },
  application: {
    name: [
      { required: true, message: '应用名称不能为空', trigger: 'blur' },
      { min: 1, max: 20, message: '应用名称不能超过20个字符', trigger: 'blur' },
    ],
    // icon: [
    //   { required: true, message: '需要上传应用图标', trigger: 'change' }
    // ],
    productList: [
      { required: true, message: '请选择所属产品', trigger: 'blur' },
    ],
    deviceType: [
      { required: true, message: '请选择适用端口', trigger: 'blur' },
    ],
    path: [{ required: true, message: '地址不能为空', trigger: 'blur' }],
    // dataAuthorityId: [
    //   { required: false, message: '请选择数据权限', trigger: 'blur' }
    // ],
    status: [
      { required: true, message: '必须选择一个应用状态', trigger: 'blur' },
    ],
  },
};
export default {
  isPhone,
  isMail,
  verifyRules,
};
